import os
import glob
from string import letters
import sys

output = []

f = open(sys.argv[2], 'w')
alphabet = sys.argv[3]

f.write('alphabet, letter, corners, height, width, convexity, complexity, diffsegs0, diffsegs1, endpoints, ratio, holes, diagConnections, connectedComponents, density, variance0, variance1, gradOrientation0, gradOrientation1, gradOrientation2, gradOrientation3, gradOrientation4, gradOrientation5, gradOrientation6, gradOrientation7, curvature\n')# gradOrientation8, gradOrientation9, gradOrientation10, gradOrientation11, gradOrientation12, gradOrientation13, gradOrientation14, gradOrientation15, holeNoise\n')

for (j, letter) in enumerate(glob.glob(os.path.join(sys.argv[1], '*.png'))):
    name = os.path.splitext(os.path.basename(letter))[0]
    output.append([])
    p = os.popen('./genFeatures {0}'.format(letter))
    f.write('{0}, {1}, {2}'.format(alphabet, name, p.readline()))
